
:root{--green:#128858;--red:#d43b55;--navy:#213547;--cream:#fffaf0;--line:#d8dfd6;--gold:#f4b942}*{box-sizing:border-box}body{margin:0;min-height:100vh;font-family:"Noto Sans Arabic",Tahoma,sans-serif;color:var(--navy);background:linear-gradient(145deg,#eef8f1,#fff8eb)}.letter-race-page{width:min(1280px,calc(100% - 20px));margin:auto;padding:24px 0 44px}.back-link{display:inline-block;margin-bottom:14px;color:#17613f;font-weight:700;text-decoration:none}.letter-game{padding:14px;border:1px solid #cfe1d5;border-radius:26px;background:rgba(255,255,255,.92);box-shadow:0 18px 50px #143d2820}.letter-game__header{text-align:center}.letter-game__header p{margin:2px;color:#5d6e65}.letter-game__header>p:first-child{color:var(--red);font-weight:800}.letter-game__header h1{margin:2px;font-size:clamp(1.8rem,5vw,2.8rem)}.player{display:grid;grid-template-columns:1fr 1fr;gap:8px;align-items:center;margin:10px 0;padding:8px;border:3px solid;border-radius:17px;background:#fff}.player--one{border-color:var(--green)}.player--two{border-color:#4169b1}.player>div:first-child{display:flex;flex-direction:column}.player__label{font-weight:800}.letter-collection{display:flex;gap:5px;align-items:center;min-height:42px;padding:5px;overflow-x:auto;border-radius:11px;background:#f7faf7}.collected-letter{display:grid;place-items:center;flex:0 0 34px;height:34px;border-radius:10px;color:#fff;background:var(--green);font-size:1.05rem;font-weight:800;box-shadow:0 5px 11px #18382822}.player--two .collected-letter{background:#4169b1}.empty-text{color:#89958e;font-size:.9rem}.game-layout{display:grid;grid-template-columns:minmax(620px,1fr) 172px;gap:12px;align-items:start}.board-panel{overflow:hidden;border:3px solid var(--navy);border-radius:17px}.board-topbar{display:flex;justify-content:space-between;padding:8px 12px;color:#fff;background:var(--navy);font-weight:700}.race-board{display:grid;grid-template-columns:repeat(10,1fr);direction:rtl;width:100%;aspect-ratio:1/1;background:#fff}.board-cell{position:relative;display:grid;place-items:center;border-right:1px solid var(--line);border-bottom:1px solid var(--line);font-size:.7rem;color:#708078}.board-cell .marker{width:42%;aspect-ratio:1;border-radius:50%;box-shadow:inset 0 -3px 4px #0002}.board-cell.green .marker{background:var(--green)}.board-cell.red .marker{background:var(--red)}.board-cell.finish{background:#fff0b9;font-weight:800}.tokens{position:absolute;inset:2px;display:flex;align-items:flex-end;justify-content:center;gap:2px}.token{display:grid;place-items:center;width:25px;height:25px;border:0;background:transparent!important;font-size:1.35rem;line-height:1;font-weight:800;text-shadow:0 1px 0 #fff,1px 0 0 #fff,-1px 0 0 #fff,0 -1px 0 #fff,0 2px 4px #0006}.token.p1{color:#2878d0}.token.p2{color:#171717}.side-panel{display:flex;flex-direction:column;gap:8px}.letter-box,.dice-panel,.legend{padding:8px;border:1px solid #d7e4da;border-radius:15px;background:#eef9f1}.letter-box h2{margin:0;font-size:.98rem}.letter-box p{margin:2px 0 6px;font-size:.68rem;line-height:1.45;color:#62766c}.letter-choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:3px;max-height:none;overflow:visible}.letter-choice{height:30px;padding:0;border:2px solid #cce3d4;border-radius:10px;background:#fff;color:#173a29;font:800 .95rem inherit;cursor:pointer}.letter-choice:disabled{opacity:.45;cursor:not-allowed}.letter-choice:not(:disabled):hover{border-color:var(--green);transform:translateY(-2px)}.dice-panel{text-align:center;background:#fff7e5}.dice{font-size:3rem;line-height:1;margin-bottom:4px}.btn{width:100%;margin-top:5px;padding:7px 8px;border:0;border-radius:10px;font:800 .82rem inherit;cursor:pointer}.btn:disabled{opacity:.5;cursor:not-allowed}.btn--primary{color:#fff;background:var(--green)}.btn--danger{color:#fff;background:var(--red)}.btn--light{color:#174a31;background:#fff;border:1px solid #bcd8c6}.legend{display:grid;gap:5px;font-size:.72rem}.legend span{display:flex;gap:7px;align-items:center}.dot{width:15px;height:15px;border-radius:50%}.dot--green{background:var(--green)}.dot--red{background:var(--red)}.message{margin:14px 0 0;padding:11px;border-radius:10px;background:#fff7d8;text-align:center;font-weight:700}.active-player{box-shadow:0 0 0 4px #f4b94255,0 10px 22px #243d3022}.winner{animation:winner .7s ease infinite alternate}@keyframes winner{to{transform:scale(1.015);box-shadow:0 0 0 6px #f4b94266}}@media(max-width:760px){.game-layout{grid-template-columns:1fr}.side-panel{display:grid;grid-template-columns:1fr 1fr}.legend{grid-column:1/-1}.player{grid-template-columns:1fr}.race-board{min-height:330px}.token{width:18px;height:18px}}@media(max-width:440px){.letter-game{padding:10px}.side-panel{grid-template-columns:1fr}.legend{grid-column:auto}.board-topbar{font-size:.78rem}.board-cell{font-size:.55rem}.race-board{min-height:310px}.token{width:15px;height:15px;font-size:.55rem}}

@media(max-width:440px){.letter-choices{grid-template-columns:repeat(4,minmax(0,1fr));max-height:270px}}

/* Board-first sizing: keep the 100-square board as the main visual. */
@media (min-width:761px){.board-panel{min-width:0}.race-board{min-height:404px}.player{width:188px;margin-inline:auto}.side-panel{position:sticky;top:10px}}
@media (max-width:760px){.game-layout{grid-template-columns:1fr}.side-panel{display:grid;grid-template-columns:1fr 1fr}.letter-box{grid-column:1/-1}.letter-choices{grid-template-columns:repeat(9,minmax(0,1fr))}.letter-choice{height:34px}.race-board{min-height:0}.dice-panel{display:grid;grid-template-columns:72px 1fr;gap:5px;align-items:center}.dice{grid-row:1/3}.legend{grid-column:1/-1}}
@media (max-width:520px){.letter-choices{grid-template-columns:repeat(7,minmax(0,1fr))}.game-layout{display:block}.side-panel{display:grid;margin-top:10px}.board-topbar{font-size:.72rem}.player{grid-template-columns:1fr}.collected-letter{flex-basis:30px;height:30px}}

/* Player markers: flower 1 is red, flower 2 is black. Board path reads right-to-left in Sorani order. */
.token.p1{color:#d0283e}.token.p2{color:#171717}
/* Refined board cells: compact grid, larger numerals, dot numerals, centred flowers. */
.game-layout{grid-template-columns:172px minmax(480px,204px);justify-content:center}
.race-board{max-width:404px;margin-inline:auto}
.board-cell{position:relative;display:block;font-size:.43rem;font-weight:800;color:#53665c}
.board-cell>.number{position:absolute;inset-block-start:2.5px;inset-inline-start:3px;z-index:1;line-height:1}
.board-cell .marker{position:absolute;inset-block-start:2.5px;inset-inline-start:2.5px;display:grid;place-items:center;width:15px;height:15px;border-radius:50%;box-shadow:inset 0 -1.5px 2px #0002}
.board-cell .marker .number{position:static;color:#fff;font-size:.39rem;line-height:1;text-shadow:0 .5px 1px #0005}
.tokens{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;gap:2px;pointer-events:none}
.token{width:14px;height:14px;font-size:.775rem;line-height:1;z-index:2}
@media(max-width:760px){.game-layout{grid-template-columns:1fr}.race-board{max-width:310px}.board-cell{font-size:.38rem}.board-cell .marker{width:13px;height:13px}.board-cell .marker .number{font-size:.34rem}}
@media(max-width:440px){.race-board{max-width:50%}.board-cell{font-size:.31rem}.board-cell>.number{inset-block-start:1.5px;inset-inline-start:1.5px}.board-cell .marker{inset-block-start:1px;inset-inline-start:1px;width:11px;height:11px}.board-cell .marker .number{font-size:.285rem}.token{width:10px;height:10px;font-size:.56rem}}

.player__summary{display:flex!important;flex-direction:column!important;align-items:center;justify-content:center;gap:2px;text-align:center}.player__flower{font-size:2rem;line-height:1;text-shadow:0 1px 0 #fff,1px 0 #fff,-1px 0 #fff,0 -1px #fff,0 2px 4px #0005}.player__flower--blue{color:#2878d0}.player__flower--black{color:#171717}.player__summary strong{font-size:.88rem}.letter-collection:empty{min-height:42px}

/* Compact paired actions, larger die, and non-scoring word space. */
.dice{font-size:6rem;line-height:1;margin-bottom:6px;direction:ltr}.dice-actions{display:grid;grid-template-columns:1fr 1fr;gap:6px;direction:rtl}.dice-actions .btn{width:100%;margin-top:0;padding-inline:4px}.collected-space{flex:0 0 22px;height:34px;border-inline-end:2px dashed #aab8b0}.letter-choice[data-space="true"]{letter-spacing:-1px}
@media(max-width:440px){.dice{font-size:5rem}.dice-actions{grid-template-columns:1fr 1fr}}

/* Status box and Sorani numeral refinements. */
.marker{font-style:normal}.marker .number{font-style:normal;font-family:"Noto Sans Arabic",Tahoma,sans-serif;font-variant-numeric:normal}.game-status-box{padding:9px;border:1px solid #d5c484;border-radius:10px;background:#fff7d8;text-align:center}.game-status-box p{margin:2px 0;font-size:.78rem;font-weight:700}.game-status-box #message{padding-top:5px;margin-top:5px;border-top:1px solid #e7d99f;color:#374d42}.player__summary strong{direction:ltr}.letter-game__header p:first-child{margin-bottom:2px}
/* Three-row word collection and special board cells. */
.letter-collection{height:110px;min-height:110px;display:flex;flex-wrap:wrap;align-content:flex-start;align-items:flex-start;gap:4px 6px;overflow-y:auto;padding:5px;line-height:1.55}
.collected-word{display:inline-block;min-height:28px;padding:2px 6px;border-radius:6px;color:#fff;background:#2878d0;font-size:.9rem;font-weight:800;white-space:nowrap}
.player--two .collected-word{background:#171717}
.word-gap{display:inline-block;flex:0 0 14px;height:28px;border-bottom:1px dashed #a8b5ad}
.special-icon{position:absolute;inset:0;display:grid;place-items:center;font-size:1.45rem;z-index:1;pointer-events:none;filter:drop-shadow(0 2px 2px #0004)}
.board-cell.bomb,.board-cell.diamond{background:#fffdf5}
.board-cell.bomb>.number,.board-cell.diamond>.number{z-index:2}
.tokens{z-index:3}
@media(max-width:760px){.letter-collection{height:48px;min-height:48px}.collected-word{font-size:.82rem;min-height:25px}.word-gap{height:25px}.special-icon{font-size:1.15rem}}

/* Larger player flowers; centred cell numbers and markers. */
.player__flower{font-size:6rem;line-height:.85}.player__summary{min-width:auto;flex:0 0 auto}.board-cell>.number{inset:50% auto auto 50%;transform:translate(-50%,-50%);font-size:.5rem}.board-cell .marker{inset:50% auto auto 50%;transform:translate(-50%,-50%);width:17px;height:17px}.board-cell .marker .number{font-size:.42rem}.special-icon{z-index:2}.tokens{z-index:4}.token{font-size:1rem}
@media(max-width:760px){.player__flower{font-size:4.8rem}.board-cell .marker{width:14.5px;height:14.5px}.board-cell>.number{font-size:.41rem}.token{font-size:.75rem}}
@media(max-width:440px){.player__flower{font-size:3.9rem}.board-cell .marker{width:11.5px;height:11.5px}.board-cell .marker .number{font-size:.29rem}.board-cell>.number{font-size:.325rem}.token{font-size:.575rem}}

/* Letter edit controls now sit above the die. */
.pick-actions{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:5px}.pick-actions .btn{width:100%;margin:0;padding:6px 3px}.btn--done{color:#fff;background:#213547}.btn--light{color:#174a31;background:#fff;border:1px solid #bdd7c6}

/* Title toolbar, about dialog, and computer mode. */
.game-toolbar{display:flex;direction:ltr;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px;padding:4px 2px}.game-toolbar h1{direction:rtl;margin:0!important;font-weight:900;text-align:left}.game-toolbar__actions{display:flex;direction:rtl;gap:7px}.toolbar-button{padding:8px 13px;border:1px solid #bcd8c6;border-radius:9px;background:#fff;color:#193d2c;font:800 .86rem inherit;cursor:pointer}.toolbar-button:hover,.toolbar-button.is-active{color:#fff;background:#213547}.about-modal[hidden]{display:none}.about-modal{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:18px;background:#10271cb8}.about-dialog{position:relative;width:min(500px,100%);padding:27px 22px 20px;border-radius:17px;background:#fff;box-shadow:0 22px 70px #0005}.about-dialog h2{margin:0 0 10px}.about-dialog p{margin:8px 0;line-height:1.8}.about-close{position:absolute;inset-block-start:8px;inset-inline-end:9px;width:34px;height:34px;border:0;border-radius:50%;background:#edf4ef;font-size:1.5rem;cursor:pointer}
@media(max-width:520px){.game-toolbar{align-items:flex-start}.game-toolbar__actions{gap:4px}.toolbar-button{padding:7px 8px;font-size:.72rem}.game-toolbar h1{font-size:1.45rem}}

.letter-choice,.btn,.toolbar-button{font-family:inherit;font-weight:800}
.letter-choice{font-size:.95rem}.btn{font-size:.82rem}.toolbar-button{font-size:.86rem}
@media(max-width:520px){.toolbar-button{font-size:.72rem}}
